<template>
  <div>
    <van-field
      readonly
      clickable
      label="所在楼层"
      :value="roomTypeItem"
      placeholder="请选择"
      @click="showPicker = true"
      input-align="right"
      right-icon="arrow"
    />

    <van-popup v-model="showPicker" round position="bottom">
      <van-picker
        show-toolbar
        :columns="roomType"
        @cancel="showPicker = false"
        @confirm="onConfirm"
      />
    </van-popup>
  </div>
</template>

<script>
export default {
  name: "floor",
  data() {
    return {
      value: "",
      showPicker: false,
      roomType: [],
      roomTypeItem: "",
    };
  },
  props: {
    releaseHomeData: {
      type: Object,
      default: () => ({}),
    },
  },
  created() {
    console.log(this.releaseHomeData);
  },
  mounted() {
    this.getRoomType();
  },
  methods: {
    getRoomType() {
      this.releaseHomeData.floor.forEach((item) => {
        this.roomType.push(item.label);
      });
    },
    onConfirm(value) {
      this.showPicker = false;
      this.roomTypeItem = value;
      const filterItem = this.releaseHomeData.floor.filter((item) => {
        return item.label === value;
      });
      this.$emit("floorType", filterItem);
    },
  },
};
</script>

<style></style>
